import {makeAutoObservable, flow} from 'mobx';
import {request} from '../../utils/request';
import Loading from '../../components/widget/Loading';

export default class ArticleDetailStore {
  detail: Article = {} as Article;

  constructor() {
    makeAutoObservable(this);
  }
  requestArticleDetail = flow(function* (this: ArticleDetailStore, id: number) {
    //   requestArticleDetail = async (id:number) => {

    Loading.show();
    try {
      const params = {
        id: id,
      };
      const {data} = yield request('articleDetail', params);
      this.detail = data || {};
    } catch (error) {
      console.log(error);
    } finally {
      Loading.hide();
    }
  })
}

